#include "user.h"
#include <QObject>

User::User(const int &ID,
           const QString &unit,
           const QString &firstName,
           const QString &secondName,
           const QString &middleName,
           const QString &post,
           const QString &contactInfo)
               : m_id(ID), m_unit(unit),
               mf_name(firstName),
               ms_name(secondName),
               mm_name(middleName),
               m_post(post),
               contact_info(contactInfo),
               m_visible(!post.isEmpty())
{}

int User::id() const
{
    return m_id;
}

QString User::name(const NameType &nameType) const
{
    if(nameType==WithPost)
        return QObject::tr("%1 %2.%3. %4").arg(mf_name)
                                          .arg(ms_name.at(0))
                                          .arg(mm_name.at(0))
                                          .arg(m_post);
    if(nameType==FIO)
        return QObject::tr("%1 %2. %3.")  .arg(mf_name)
                                          .arg(ms_name.at(0))
                                          .arg(mm_name.at(0));
    if(nameType==FullName)
        return QObject::tr("%1 %2 %3").arg(mf_name).arg(ms_name).arg(mm_name);
    if(nameType==SMName)
        return QObject::tr("%1 %2").arg(ms_name).arg(mm_name);
    return "";
}

bool User::isVisible() const
{
    return m_visible;
}

QString User::unit() const
{
    return m_unit;
}
